
import java.util.HashMap;
import java.util.Map;

/**
 * @author Matan Mizrahi,Chen weissman
 * Introduction to computer science, assingment5
 * Date:2.1.2011
 *
 * A class which objects represent assignments of values
 * to sets of variables. 
 */
public class Assignment
{
	private Map<Character, Double> valueMap;

	/**
	 * 
	 * Constructor. Creates data structure.
	 */
	public Assignment()
	{
		valueMap = new HashMap<Character, Double>();
	}

	/**
	 * 
	 * Sets the value of a specific variable. If no previous
	 * value was assign to the given variable, the variable
	 * will be added to the assignment. Otherwise, the new
	 * given value will override the previous value that was
	 * assigned to the variable.
	 * 
	 * @param varName the name of the variable.
	 * @param value the value to assign to the variable.
	 * 
	 */
	void setVarValue(char varName, double value)
	{
		valueMap.put(new Character(varName), new Double(value));
	}

	/**
	 * 
	 * Gets the value of some variable under this assignment.
	 * 
	 * @param varName the name of the variable.
	 * @return The value of the variable under the assignment in the
	 * case where the variable was assigned a value, and {@code null} otherwise. 
	 */
	Double getVarValue(char varName)
	{
		return valueMap.get(new Character(varName));
	}
}
